package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.Project;
import com.zygh.policeasset.pojo.Purchase;
import com.zygh.policeasset.pojo.export.ExportPurchase;
import com.zygh.policeasset.pojo.vo.ProjectInfoVO;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

@Mapper
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/PurchaseMapper.class */
public interface PurchaseMapper {
    @Insert({"insert into purchase (purchase_no,purchase_name,purchase_type, get_datetime, brand,retailer, asset_name,project_no, gaining_type, purpose,models, manufacturer, start_datetime,guarantee_stop_datetime, depreciation_year,money_type, money, depreciation_status,condition_status, condition_section_name, storage, user_num, manage_section_num, purchase_time,input_num, status_num,data_labels_id) values ( #{purchaseNo}, #{purchaseName,jdbcType=VARCHAR},#{purchaseType,jdbcType=VARCHAR}, #{getDatetime,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR}, #{retailer,jdbcType=VARCHAR}, #{assetName,jdbcType=VARCHAR},#{projectNo,jdbcType=VARCHAR}, #{gainingType,jdbcType=VARCHAR}, #{purpose,jdbcType=VARCHAR},#{models,jdbcType=VARCHAR}, #{manufacturer,jdbcType=VARCHAR}, #{startDatetime,jdbcType=VARCHAR},#{guaranteeStopDatetime,jdbcType=VARCHAR}, #{depreciationYear,jdbcType=VARCHAR},#{moneyType,jdbcType=VARCHAR}, #{money,jdbcType=VARCHAR}, #{depreciationStatus,jdbcType=VARCHAR},#{conditionStatus,jdbcType=VARCHAR}, #{conditionSectionName,jdbcType=VARCHAR}, #{storage,jdbcType=VARCHAR}, #{userNum,jdbcType=VARCHAR}, #{manageSectionNum,jdbcType=VARCHAR},#{purchaseTime,jdbcType=VARCHAR},#{inputNum,jdbcType=INTEGER}, #{statusNum,jdbcType=VARCHAR}, #{dataLabelsId,jdbcType=INTEGER})"})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int add(Purchase purchase);

    @Update({"update purchase set purchase_name = #{purchaseName,jdbcType=VARCHAR},purchase_type = #{purchaseType,jdbcType=VARCHAR},get_datetime = #{getDatetime,jdbcType=VARCHAR},brand = #{brand,jdbcType=VARCHAR},retailer = #{retailer,jdbcType=VARCHAR},asset_name = #{assetName,jdbcType=VARCHAR},project_no = #{projectNo,jdbcType=VARCHAR},gaining_type = #{gainingType,jdbcType=VARCHAR},purpose = #{purpose,jdbcType=VARCHAR},models = #{models,jdbcType=VARCHAR},manufacturer = #{manufacturer,jdbcType=VARCHAR},start_datetime = #{startDatetime,jdbcType=VARCHAR},guarantee_stop_datetime = #{guaranteeStopDatetime,jdbcType=VARCHAR},depreciation_year = #{depreciationYear,jdbcType=VARCHAR},money_type = #{moneyType,jdbcType=VARCHAR},money = #{money,jdbcType=VARCHAR},depreciation_status = #{depreciationStatus,jdbcType=VARCHAR},condition_status = #{conditionStatus,jdbcType=VARCHAR},condition_section_name = #{conditionSectionName,jdbcType=VARCHAR},storage = #{storage,jdbcType=VARCHAR},user_num = #{userNum,jdbcType=VARCHAR},manage_section_num = #{manageSectionNum,jdbcType=VARCHAR},images = #{images,jdbcType=VARCHAR},purchase_time = #{purchaseTime,jdbcType=VARCHAR},input_num = #{inputNum,jdbcType=INTEGER},pact_app_num = #{pactAppNum,jdbcType=INTEGER},pact_app_content = #{pactAppContent,jdbcType=VARCHAR},pact_app_status = #{pactAppStatus,jdbcType=VARCHAR},money_app_num = #{moneyAppNum,jdbcType=INTEGER},money_app_content = #{moneyAppContent,jdbcType=VARCHAR},money_app_status = #{moneyAppStatus,jdbcType=VARCHAR},status_num = #{statusNum,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER}"})
    int updateById(Purchase purchase);

    @Delete({"delete from purchase where id = #{id,jdbcType=INTEGER}"})
    int deleteById(Integer num);

    @Select({"SELECT p.*,i.connect,i.create_date FROM purchase p LEFT JOIN images i ON p.id = i.assets_id WHERE p.id= #{id,jdbcType=INTEGER} and i.type = 'cg' "})
    @Results({@Result(property = "purchaseNo", column = "purchase_no"), @Result(property = "purchaseName", column = "purchase_name"), @Result(property = "purchaseType", column = "purchase_type"), @Result(property = "getDatetime", column = "get_datetime"), @Result(property = "assetName", column = "asset_name"), @Result(property = "projectNo", column = "project_no"), @Result(property = "gainingType", column = "gaining_type"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "guaranteeStopDatetime", column = "guarantee_stop_datetime"), @Result(property = "depreciationYear", column = "depreciation_year"), @Result(property = "moneyType", column = "money_type"), @Result(property = "depreciationStatus", column = "depreciation_status"), @Result(property = "conditionStatus", column = "condition_status"), @Result(property = "conditionSectionName", column = "condition_section_name"), @Result(property = "userNum", column = "user_num"), @Result(property = "manageSectionNum", column = "manage_section_num"), @Result(property = "standbyFields", column = "standby_fields"), @Result(property = "purchaseTime", column = "purchase_time"), @Result(property = "inputNum", column = "input_num"), @Result(property = "pactAppNum", column = "pact_app_num"), @Result(property = "pactAppContent", column = "pact_app_content"), @Result(property = "pactAppStatus", column = "pact_app_status"), @Result(property = "moneyAppNum", column = "money_app_num"), @Result(property = "moneyAppContent", column = "money_app_content"), @Result(property = "moneyAppStatus", column = "money_app_status"), @Result(property = "statusNum", column = "status_num"), @Result(property = "connect", column = "connect"), @Result(property = "createDate", column = "create_date"), @Result(property = "paymentTime", column = "payment_time")})
    Map findById(Integer num);

    @Select({"<script>", "select d.id, d.purchase_no, d.purchase_name, d.purchase_type, d.get_datetime, d.brand, d.retailer, d.asset_name,d.gaining_type, d.purpose,d.models, d.manufacturer, d.start_datetime, d.guarantee_stop_datetime, d.depreciation_year,d.money_type, d.money,d.depreciation_status, d.condition_status, d.condition_section_name, d.storage,  d.user_num,d.manage_section_num, d.images, d.purchase_time, d.input_num,d.pact_app_num,d.pact_app_content, d.pact_app_status, d.money_app_num,d.money_app_content,d.money_app_status, d.status_num, d.payment_time,d.start_provision_date,d.assets_classification_id,d.assets_classification_pid,ac1.`name` AS assetsClassificationPName,ac.`name` AS assetsClassificationName  from purchase d LEFT JOIN assets_classification ac1 ON d.assets_classification_pid=ac1.id LEFT JOIN assets_classification ac ON d.assets_classification_id=ac.id <where><if test='projectNo != null and projectNo.length &gt; 0'>and project_no = #{projectNo,jdbcType=VARCHAR} </if><if test='purchaseName != null and purchaseName.length &gt; 0'>and purchase_name = #{purchaseName,jdbcType=VARCHAR} </if><if test='assetsClassificationId == 0'> and d.assets_classification_id  IS  NULL </if><if test='assetsClassificationId == 1'> and d.assets_classification_id IS NOT NULL </if></where> </script>"})
    @Results({@Result(property = "purchaseNo", column = "purchase_no"), @Result(property = "purchaseName", column = "purchase_name"), @Result(property = "purchaseType", column = "purchase_type"), @Result(property = "getDatetime", column = "get_datetime"), @Result(property = "assetName", column = "asset_name"), @Result(property = "gainingType", column = "gaining_type"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "guaranteeStopDatetime", column = "guarantee_stop_datetime"), @Result(property = "depreciationYear", column = "depreciation_year"), @Result(property = "moneyType", column = "money_type"), @Result(property = "depreciationStatus", column = "depreciation_status"), @Result(property = "conditionStatus", column = "condition_status"), @Result(property = "conditionSectionName", column = "condition_section_name"), @Result(property = "userNum", column = "user_num"), @Result(property = "manageSectionNum", column = "manage_section_num"), @Result(property = "purchaseTime", column = "purchase_time"), @Result(property = "inputNum", column = "input_num"), @Result(property = "pactAppNum", column = "pact_app_num"), @Result(property = "pactAppContent", column = "pact_app_content"), @Result(property = "pactAppStatus", column = "pact_app_status"), @Result(property = "moneyAppNum", column = "money_app_num"), @Result(property = "moneyAppContent", column = "money_app_content"), @Result(property = "moneyAppStatus", column = "money_app_status"), @Result(property = "statusNum", column = "status_num"), @Result(property = "paymentTime", column = "payment_time"), @Result(property = "startProvisionDate", column = "start_provision_date"), @Result(property = "assetsClassificationId", column = "assets_classification_id", jdbcType = JdbcType.INTEGER), @Result(property = "assetsClassificationPid", column = "assets_classification_pid", jdbcType = JdbcType.INTEGER)})
    List<Purchase> findOneAll(String str, String str2, Integer num);

    @Select({"<script>", "select id, purchase_no, purchase_name, purchase_type, get_datetime, brand, retailer, asset_name,gaining_type, purpose,models, manufacturer, start_datetime, guarantee_stop_datetime, depreciation_year,money_type, money,depreciation_status, condition_status, condition_section_name, storage,  user_num,manage_section_num, images, purchase_time, input_num, pact_app_num,pact_app_content, pact_app_status, money_app_num, money_app_content, money_app_status, status_num, payment_time from purchase <where><if test='projectNo != null and projectNo.length &gt; 0'>and project_no = #{projectNo,jdbcType=VARCHAR} </if></where> </script>"})
    @Results({@Result(property = "purchaseNo", column = "purchase_no"), @Result(property = "purchaseName", column = "purchase_name"), @Result(property = "purchaseType", column = "purchase_type"), @Result(property = "getDatetime", column = "get_datetime"), @Result(property = "gainingType", column = "gaining_type"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "guaranteeStopDatetime", column = "guarantee_stop_datetime"), @Result(property = "depreciationYear", column = "depreciation_year"), @Result(property = "moneyType", column = "money_type"), @Result(property = "depreciationStatus", column = "depreciation_status"), @Result(property = "conditionStatus", column = "condition_status"), @Result(property = "conditionSectionName", column = "condition_section_name"), @Result(property = "userNum", column = "user_num"), @Result(property = "manageSectionNum", column = "manage_section_num"), @Result(property = "assetName", column = "asset_name")})
    List<ExportPurchase> exportExcel(String str);

    @Update({"update purchase set status_num = #{statusNum,jdbcType=VARCHAR} where project_no = #{projectNo,jdbcType=VARCHAR}"})
    int submit(@Param("projectNo") String str, @Param("statusNum") String str2);

    @Update({"update purchase set purchase_no = #{purchaseNo,jdbcType=VARCHAR},pact_app_num = #{pactAppNum,jdbcType=INTEGER},pact_app_content = #{pactAppContent,jdbcType=VARCHAR},pact_app_status = '5',status_num = '5' where id = #{id} "})
    int app(Purchase purchase);

    @Update({"update purchase set pact_app_num = #{pactAppNum,jdbcType=INTEGER},pact_app_content = #{pactAppContent,jdbcType=VARCHAR},pact_app_status = '6',status_num = '6' where project_no = #{projectNo,jdbcType=VARCHAR}"})
    int apperror(Purchase purchase);

    @Select({"<script>", "select p.name,p.project_no,p.company_apply,af.approval_steps_id as approvalStepsId,p.capital_source,p.budget,p.contactor,p.start_datetime,c.type as type,p.certificate_num,p.start_provision_date,c.name as categoryName,af.app_status,u.name as userName,cy.company_name as companyName,af.app_status,u.name as userName,pab.flow_no,pab.id as id from purchase_assets_business pab LEFT JOIN project p on pab.project_id = p.id LEFT JOIN category c on p.category=c.id LEFT JOIN company cy on p.retailer_id=cy.id left join audit_flow af on pab.flow_no = af.flow_no left join user u on af.applicant = u.id <where>and p.category =4 AND p.pid != 0  <if test='name != null and name.length &gt; 0'>and p.name like '%${name}%' </if><if test='dataLabelsId != null'>and p.data_labels_id = #{dataLabelsId} </if><if test='userId != null '> and af.applicant=#{userId} </if><if test=' status != null'> and af.app_status = #{status} </if><if test='unitId != null  ' > and p.retailer_id = #{unitId} </if></where> order by p.id desc</script>"})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "companyApply", column = "company_apply"), @Result(property = "capitalSource", column = "capital_source"), @Result(property = "projectBase", column = "project_base"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "paymentTime", column = "payment_time"), @Result(property = "startProvisionDate", column = "start_provision_date"), @Result(property = "certificateNum", column = "certificate_num"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "appStatus", column = "app_status")})
    List<Project> findByStatus(@Param("status") Integer status,
                               @Param("dataLabelsId") Integer dataLabelsId,
                               @Param("name") String name,
                               @Param("userId") Integer userId,
                               @Param("unitId") Integer unitId);

    @Select({"<script>", "select pab.id,p.name,p.project_no,p.company_apply,af.approval_steps_id as approvalStepsId,p.capital_source,p.budget,p.contactor,p.start_datetime,c.type as type,c.name as categoryName,af.app_status,u.name as userName,cy.company_name as companyName,pab.flow_no from purchase_assets_business pab LEFT JOIN project p on pab.project_id = p.id LEFT JOIN category c on p.category=c.id LEFT JOIN company cy on p.retailer_id=cy.id left join audit_flow af on pab.flow_no = af.flow_no left join user u on af.applicant = u.id <where>and p.category =4 AND p.pid != 0  <if test='id != null '>and pab.id  = #{id} </if></where></script>"})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "companyApply", column = "company_apply"), @Result(property = "capitalSource", column = "capital_source"), @Result(property = "projectBase", column = "project_base"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "paymentTime", column = "payment_time"), @Result(property = "startProvisionDate", column = "start_provision_date"), @Result(property = "certificateNum", column = "certificate_num"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "appStatus", column = "app_status")})
    Project findbyId(@Param("id") Integer num);

    @Select({"<script>", "select p.name as projectName,p.project_no as buildNum,p.retailer_id as companyId from project p LEFT JOIN category c on p.category=c.id <where> p.category =4 AND p.pid != 0 <if test='name != null and name.length &gt; 0'>and p.name like '%${name}%' </if><if test='unitId != null  ' > and p.retailer_id = #{unitId} </if></where> order by p.id desc</script>"})
    List<ProjectInfoVO> getProjectInfo(@Param("name") String str, @Param("unitId") Integer num);

    @Select({"select count(*) from project p left join new_approval_process nap on p.project_no = nap.build_num and nap.id =( SELECT id FROM new_approval_process na WHERE p.project_no = na.build_num ORDER BY id DESC LIMIT 1)where nap.user_id = #{userId} and nap.approval_status = 1  and p.category =4 AND p.pid != 0 "})
    Integer findAssetsAppCount(Integer num);

    @Update({"update purchase set payment_time = #{paymentTime,jdbcType=VARCHAR} where project_no = #{projectNo,jdbcType=VARCHAR}"})
    int affirmPay(@Param("projectNo") String str, @Param("paymentTime") String str2);

    @Select({"select *  from purchase where project_no = #{purchase_no}  "})
    @Results(id = "purMap", value = {@Result(property = "purchaseNo", column = "purchase_no"), @Result(property = "purchaseName", column = "purchase_name"), @Result(property = "purchaseType", column = "purchase_type"), @Result(property = "getDatetime", column = "get_datetime"), @Result(property = "assetName", column = "asset_name"), @Result(property = "projectNo", column = "project_no"), @Result(property = "gainingType", column = "gaining_type"), @Result(property = "startDatetime", column = "start_datetime"), @Result(property = "guaranteeStopDatetime", column = "guarantee_stop_datetime"), @Result(property = "depreciationYear", column = "depreciation_year"), @Result(property = "moneyType", column = "money_type"), @Result(property = "depreciationStatus", column = "depreciation_status"), @Result(property = "conditionStatus", column = "condition_status"), @Result(property = "conditionSectionName", column = "condition_section_name"), @Result(property = "userNum", column = "user_num"), @Result(property = "manageSectionNum", column = "manage_section_num"), @Result(property = "standbyFields", column = "standby_fields"), @Result(property = "purchaseTime", column = "purchase_time"), @Result(property = "inputNum", column = "input_num"), @Result(property = "pactAppNum", column = "pact_app_num"), @Result(property = "pactAppContent", column = "pact_app_content"), @Result(property = "pactAppStatus", column = "pact_app_status"), @Result(property = "moneyAppNum", column = "money_app_num"), @Result(property = "moneyAppContent", column = "money_app_content"), @Result(property = "moneyAppStatus", column = "money_app_status"), @Result(property = "statusNum", column = "status_num"), @Result(property = "connect", column = "connect"), @Result(property = "createDate", column = "create_date"), @Result(property = "paymentTime", column = "payment_time"), @Result(column = "data_labels_id", property = "dataLabelsId", jdbcType = JdbcType.INTEGER), @Result(column = "start_provision_date", property = "startProvisionDate", jdbcType = JdbcType.VARCHAR)})
    List<Purchase> findByProjectNo(@Param("purchase_no") String str);

    @Update({"update purchase set start_provision_date=#{startProvisionDate} where project_no = #{buildNum} "})
    Integer updateStartProvisionDate(@Param("startProvisionDate") String str, @Param("buildNum") String str2);

    @Update({"update purchase set assets_classification_id=#{assetsClassificationId},assets_classification_pid = #{assetsClassificationPid}  where id = #{id} "})
    Integer updateassetsClassification(@Param("id") Integer num, @Param("assetsClassificationId") Integer num2, @Param("assetsClassificationPid") Integer num3);

    @Select({"select count(*) from purchase  where project_no = #{buildNum} "})
    Integer findByBuildNum(@Param("buildNum") String str);

    @Select({"select * from purchase"})
    @ResultMap({"purMap"})
    List<Purchase> findAll();

    @Select({"<script>", "select p.name as projectName,p.project_no as buildNum from project p LEFT JOIN category c on p.category=c.id <where> p.category =4 AND p.pid != 0 <if test='name != null and name.length &gt; 0'>and p.name like '%${name}%' </if></where> order by p.id desc</script>"})
    List<ProjectInfoVO> getProjectByName(@Param("name") String str);
}